cmake_minimum_required(VERSION 3.10.2)

project( ThresholdAnImage )

find_package( ITK REQUIRED )
include( ${ITK_USE_FILE} )

add_executable( ThresholdAnImage Code.cxx )
target_link_libraries( ThresholdAnImage ${ITK_LIBRARIES} )

install( TARGETS ThresholdAnImage
  DESTINATION bin/ITKSphinxExamples/Filtering/Thresholding
  COMPONENT Runtime
  )

install( FILES Code.cxx CMakeLists.txt
  DESTINATION share/ITKSphinxExamples/Code/Filtering/Thresholding/ThresholdAnImage
  COMPONENT Code
  )

enable_testing()
add_test( NAME ThresholdAnImageTest
  COMMAND ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/ThresholdAnImage
    ${CMAKE_CURRENT_BINARY_DIR}/Gourds.png
    ${CMAKE_CURRENT_BINARY_DIR}/Output.png
    64
    128
  )

if( ITK_WRAP_PYTHON )
  add_test( NAME ThresholdAnImageTestPython
    COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/Code.py
      ${CMAKE_CURRENT_BINARY_DIR}/Gourds.png
      ${CMAKE_CURRENT_BINARY_DIR}/OutputPython.png
      64
      128
    )
endif()
